﻿using System.Web.Http;
using AttributeRouting.Web.Http;
using Pansoft.Authority.Entities;
using Pansoft.Authority.Interfaces;
using Pansoft.HIME.Base.Entities;
using Pansoft.HIME.Base.ViewModels;
using Pansoft.HIME.Repository;

namespace Pansoft.HIME.Controllers.Api.OrganizationManager
{
    public class OrganizationController : ApiController, IOrganizationController
    {
        #region Implementation of ICRUDBaseController<OrganizationBase,in string>

        /// <summary>创建一条实体数据
        /// </summary>
        public bool Create(OrganizationBase entity)
        {
            throw new System.NotImplementedException();
        }

        /// <summary>删除一条实体数据
        /// </summary>
        public bool Delete(string id)
        {
            throw new System.NotImplementedException();
        }

        /// <summary>更新一条实体数据
        /// </summary>
        public bool Update(OrganizationBase entity)
        {
            throw new System.NotImplementedException();
        }

        /// <summary>按基础索引键进行查询
        /// </summary>
        public OrganizationBase Retrieve(string id, bool containDeleted = false)
        {
            throw new System.NotImplementedException();
        }

        #endregion

        [POST("Organization/List")]
        public OrganizationViewModel[] List()
        {
            var list = RepositoriesFactory.Instance.OrganizationRepository.List();
            var array = new OrganizationViewModel[list.Length];
            for (int i = 0; i < list.Length; i++)
            {
                var vm = new OrganizationViewModel();
                vm.Translate(list[i]);
                array[i] = vm;
            }
            return array;
        }
    }
}
